import request from "@/utils/request";
import type { addMajorResponseData, deleteMajorResponseData, listMajorResponseData, majorInfoData, pageMajorData, pageMajorResponseData } from "./type";

//@ts-ignore
enum API{
    ADD_MAJOR = "/manage/major/add",
    FIND_BY_ID = "/manage/major/find",
    UPDATE_MAJOR = "/manage/major/update",
    GET_ALL_MAJOR = "/manage/major/all",
    PAGE_MAJOR = "/manage/major/list",
    DELETE_MAJOR = "/manage/major/delete"
}

//添加专业
export const reqAddMajor = (data:majorInfoData)=>request.post<any,addMajorResponseData>(API.ADD_MAJOR,data);
//根据id查询专业
export const reqMajorFindById = (_id:string)=>request.get<any,addMajorResponseData>(API.FIND_BY_ID+`?_id=${_id}`);
//更新专业信息
export const reqUpdateMajor = (data:majorInfoData)=>request.post<any,addMajorResponseData>(API.UPDATE_MAJOR,data);
//获取所有专业列表
export const reqAllMajor = ()=>request.get<any,listMajorResponseData>(API.GET_ALL_MAJOR);
//获取专业列表（分页）
export const reqPageMajor = (data:pageMajorData)=>request.post<any,pageMajorResponseData>(API.PAGE_MAJOR,data);
//删除专业
export const reqDeleteMajor = (majorId:string)=>request.post<any,deleteMajorResponseData>(API.DELETE_MAJOR,{majorId});